import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { getUserInfo } from '../api/request';
import { listExam } from '../api/api-all';

@Component({
  selector: 'app-page-dashboard',
  templateUrl: './page-dashboard.component.html',
  styleUrls: ['./page-dashboard.component.scss']
})
export class PageDashboardComponent implements OnInit {

  constructor(private router: Router) { }

  // 用户信息
  userInfo: any

  // 试卷概览
  taskData: any = []
  examPaperData: any = []

  ngOnInit(): void {
    this.userInfo = getUserInfo();
    listExam(0, 5).then(res => {
      this.taskData = res
    })
    listExam(1, 5).then(res => {
      this.examPaperData = res
    })

  }

  // 跳转到试卷页面
  goExam(examId: any) {
    console.log("即将跳转到考试页面:" + examId)
    this.router.navigate(['/starnight-student/exam'], {
      queryParams: { examId }
    })
  }

}
